package com.qs.controller;


import com.qs.model.dto.CollectStoreDto;
import com.qs.model.dto.GoodsIndexDto;
import com.qs.model.entity.CollectGoods;
import com.qs.model.entity.CollectStore;
import com.qs.response.Response;
import com.qs.service.ICollectGoodsService;
import com.qs.service.ICollectStoreService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户关注店铺表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-04-02
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/collect")
public class CollectStoreController {

    private final ICollectStoreService service;

    /**
     * 收藏店铺
     * @param store
     * @return
     */
    @PostMapping("/store")
    public Response handleCollectStore(@RequestBody CollectStore store){
        service.handleCollectStore(store);
        return Response.success();
    }

    /**
     * 收藏店铺数据查询
     * @param userId
     * @return
     */
    @GetMapping("/current/query/{userId}")
    public Response queryCollectStore(@PathVariable("userId") Integer userId){
        List<CollectStoreDto> list = service.queryCollectStore(userId);
        return Response.success(list);
    }
}
